/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package isvp.implementations;

import isvp.constants.ComponentConstants;
import isvp.interfaces.Privilege;
import isvp.utilities.XMLUtils;
import org.w3c.dom.Node;

/**
 *
 * @author jjophin
 */
public class PrivilegeImpl implements Privilege{
    private Node privilegeXML;
    private String privilegeFileName;    
    protected String privilegeId;
    protected String privilegeName;
    protected String privilegeDescription;
    protected String cordysRole;
    protected String menuKey;
    protected Node psvPrivilege;
    protected Node mobilePrivileges;
    protected Node menuXML;
    protected Node formPrivileges;
    protected Node boAccessRights;
    protected Node labelPrivileges;
    protected Node readFilter;
    protected Node insertFilter;
    protected Node updateFilter;
    protected Node deleteFilter;
    protected Node attachmentFilter;

    public PrivilegeImpl(Node privilegeXML, String privilegeFileName) {
        this.privilegeXML = privilegeXML;
        this.privilegeFileName = privilegeFileName;
        setPrivilegeId();
        setPrivilegeName();
        setPrivilegeDescription();
        setMenuKey();
        setCordysRole();
        setPsvPrivilege();
        setMobilePrivileges();
        setMenuXML();
        setFormPrivileges();
        setBOAccessRights();
        setLabelPrivileges();
        setReadFilter();
        setUpdateFilter();
        setInsertFilter();
        setDeleteFilter();
        setAttachmentFilter();
    }
    
    // Setter functions
    public void setPrivilegeXML(Node privilegeXML) {
        this.privilegeXML = privilegeXML;
    }
    
    public void setPrivilegeFileName(String privilegeFileName) {
        this.privilegeFileName = privilegeFileName;
    }
    
    public void setPrivilegeId() {
        this.privilegeId = XMLUtils.getTextContent(privilegeXML, ComponentConstants.PRIVILGE_ID_XPATH);
    }
    
    public void setPrivilegeName() {
        this.privilegeName = XMLUtils.getTextContent(privilegeXML, ComponentConstants.PRIVILEGE_NAME_XPATH);
    }  
    
    public void setPrivilegeDescription() {
        this.privilegeDescription = XMLUtils.getTextContent(privilegeXML, ComponentConstants.PRIVILGE_DESCRIPTION_XPATH);
    }    
    
    public void setCordysRole() {
        this.cordysRole = XMLUtils.getTextContent(privilegeXML, ComponentConstants.PRIVILEGE_CORDYS_ROLE_XPATH);
    }

    public void setMenuKey() {
        this.menuKey = XMLUtils.getTextContent(privilegeXML, ComponentConstants.PRIVILEGE_MENUKEY_XPATH);
    }
    
    public void setPsvPrivilege() {
        this.psvPrivilege = XMLUtils.getXMLNode(privilegeXML, ComponentConstants.PSV_PRIVILEGE_XPATH);
    }
    
    public void setMobilePrivileges() {
        this.mobilePrivileges = XMLUtils.getXMLNode(privilegeXML, ComponentConstants.MOBILE_PRIVILEGES_XPATH);
    }
    
    public void setMenuXML() {
        this.menuXML = XMLUtils.getXMLNode(privilegeXML, ComponentConstants.PRIVILEGE_MENUXML_XPATH);
    }    

    public void setFormPrivileges() {
        this.formPrivileges = XMLUtils.getXMLNode(privilegeXML, ComponentConstants.FORM_PRIVILEGES_XPATH);
    }
    
    public void setBOAccessRights() {
        this.boAccessRights = XMLUtils.getXMLNode(privilegeXML, ComponentConstants.PRIVILEGE_BOACCESSRIGHTS_XPATH);
    }

    public void setLabelPrivileges() {
        this.labelPrivileges = XMLUtils.getXMLNode(privilegeXML, ComponentConstants.LABEL_PRIVILEGES_XPATH);
    }

    public void setReadFilter() {
        this.readFilter = XMLUtils.getXMLNode(privilegeXML, ComponentConstants.PRIVILEGE_READ_FILTER_XPATH);
    }

    public void setInsertFilter() {
        this.insertFilter = XMLUtils.getXMLNode(privilegeXML, ComponentConstants.PRIVILEGE_INSERT_FILTER_XPATH);
    }

    public void setUpdateFilter() {
        this.updateFilter = XMLUtils.getXMLNode(privilegeXML, ComponentConstants.PRIVILEGE_UPDATE_FILTER_XPATH);
    }
    
    public void setDeleteFilter() {
        this.deleteFilter = XMLUtils.getXMLNode(privilegeXML, ComponentConstants.PRIVILEGE_DELETE_FILTER_XPATH);
    }

    public void setAttachmentFilter() {
        this.attachmentFilter = XMLUtils.getXMLNode(privilegeXML, ComponentConstants.PRIVILEGE_ATTACHMENT_FILTER_XPATH);
    }
    
    // Getter functions
    @Override
    public String getPrivilegeFileName() {
        return privilegeFileName;
    }

    public Node getPrivilegeXML() {
        return privilegeXML;
    }

    @Override
    public Node getBOAccessRights() {
        return boAccessRights;
    }

    @Override
    public String getCordysRole() {
        return cordysRole;
    }

    @Override
    public String getMenuKey() {
        return menuKey;
    }

    @Override
    public Node getFormPrivileges() {
        return formPrivileges;
    }

    @Override
    public Node getLabelPrivileges() {
        return labelPrivileges;
    }

    @Override
    public Node getMenuXML() {
        return menuXML;
    }

    @Override
    public Node getMobilePrivileges() {
        return mobilePrivileges;
    }

    @Override
    public String getPrivilegeDescription() {
        return privilegeDescription;
    }

    @Override
    public String getPrivilegeId() {
        return privilegeId;
    }

    @Override
    public String getPrivilegeName() {
        return privilegeName;
    }

    @Override
    public Node getPsvPrivilege() {
        return psvPrivilege;
    }

    @Override
    public Node getReadFilter() {
        return readFilter;
    }

    @Override
    public Node getDeleteFilter() {
        return deleteFilter;
    }

    @Override
    public Node getUpdateFilter() {
        return updateFilter;
    }

    @Override
    public Node getInsertFilter() {
        return insertFilter;
    }

    @Override
    public Node getAttachmentFilter() {
        return attachmentFilter;
    }

    @Override
    public String getNodeName() {
        String nodeName = getPrivilegeName();
        return nodeName;
    }
}
